{% extends 'base.html' %}
{% load static %}
{% block title %}首页{% endblock %}

{% block main %}
    <h1 class="text-center">博客列表</h1>
    <!-- Bootstrap row -->
    <div class="row row-cols-2 row-gap-4">
        {% for blog in blogs %}
            <div class="col"> <!-- Bootstrap column -->
                <div class="card"> <!-- Bootstrap card -->
                    <div class="card-header">
                        <a href="{% url 'app1:blog_detail' blog.id%}">{{ blog.title }}</a>
                    </div>
                    <div class="card-body" style="height: 100px">
                        <p class="card-text">{{ blog.content|striptags|truncatechars:30 }}</p>
                    </div>
                    <div class="card-footer text-body-secondary d-flex justify-content-between">
                        <div>
                            <img src="{% static 'images/avatar.png' %}" class="rounded-circle" alt="" width="30"
                                 height="30">
                            {{ blog.author.username }}
                        </div>
                        <div>发布时间：{{ blog.pub_time|date:"Y-m-d- H:i"}}</div>
                    </div>
                </div>
            </div>
        {% endfor %}

    </div>
{% endblock %}
